<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>欢迎页</title>
    <link rel="stylesheet" href="../../static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/frame/static/css/style.css">
    <link rel="icon" href="../../static/frame/static/image/code.png">
</head>
<body class="body">
<div class="layui-row layui-col-space10 my-index-main">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">选择应用</label>
            <div class="layui-input-block">
                <select id="applist" name="applist" lay-search required lay-verify="required">
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">套餐名称</label>
            <div class="layui-input-block">
                <input type="text" name="fid_name" required lay-verify="required" placeholder="请输入名称" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <input type="text" name="fid_introduce"
               class="layui-input layui-hide" hidden>
        <!--  尚未启用
        <div class="layui-form-item">
            <label class="layui-form-label">套餐介绍</label>
            <div class="layui-input-block">
                <input type="text" name="fid_introduce" required lay-verify="required" placeholder="用于首页显示" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        -->
        <div class="layui-form-item">
            <label class="layui-form-label">购买价格</label>
            <div class="layui-input-block">
                <input type="text" name="fid_price" required lay-verify="required" placeholder="用户前台购买的价格"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">代理价格</label>
            <div class="layui-input-block">
                <input type="text" name="fid_agentprice" required lay-verify="required" placeholder="代理中心购买价格"
                       autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux">注意：代理购买时候的实际支付价格 = 这里的代理价格 × 代理等级设置的提卡折率</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">授权数量</label>
            <div class="layui-input-block">
                <input type="text" name="fid_count" required lay-verify="required" placeholder="套餐包含的授权数量"
                       autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux">如果使用方式为扣除余额，则为余额数量(点)，如果使用方式为到期时间，则为使用分钟数。填-1则不会到期</div>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">套餐控制</label>
            <div class="layui-input-block">
                <input type="checkbox" name="openbuy" title="前台购买" checked>
                <input type="checkbox" name="agentbuy" title="代理开通" checked>
                <input type="checkbox" name="keybuy" title="可用充值卡" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" onclick="$('#buybody').html(' ')">重置</button>
            </div>
        </div>
    </form>
</div>

<script src="../../static/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../static/frame/layui/layui.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/frame/echarts/echarts.min.js"></script>
<script>
    //Demo
    layui.use('form', function () {

        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            data.field.id = data.field.applist;
            var loading = layer.load();
            $.ajax({
                url: '../ajax.php?mod=addfid',
                type: 'POST',
                dataType: 'html',
                data: 'content=' + encodeURI(JSON.stringify(data.field)),
                success: function (data) {
                    layer.close(loading);
                    layer.alert(data);
                },
                error: function (data) {
                    layer.close(loading);
                    layer.msg('请求失败' + data);
                }
            });

            return false;
        });


        var load = layer.load();
        $.ajax({
            url: '../ajax.php?mod=user_applist',
            type: 'POST',
            dataType: 'html',
            data: '',
            success: function (data) {
                layer.close(load);
                $('#applist').html(data);
                form.render('select');
                //layer.msg(data);

            },
            error: function (data) {
                layer.close(load);
                layer.msg('请求失败' + data);
            }
        })


    });

</script>
</body>
</html>